import os
import shutil
import json
from Utils import *
file_path = os.path.abspath(__file__)
dir_path = os.path.dirname(file_path).replace("\\file","")

desAssets = dir_path.replace("\\tools","\\settings\\builder.json")

with open(desAssets, 'r') as file:
    jsonData = json.load(file)
# with open(desAssets, 'r') as file:
#     tex_read = file.read()

if jsonData['android']['packageName'].find("cocos2d") > 0 :
    jsonData['android']['packageName'] = jsonData['android']['packageName'].replace("cocos2d","jufeng")
elif jsonData['android']['packageName'].find("jufeng") > 0 :
    jsonData['android']['packageName'] = jsonData['android']['packageName'].replace("jufeng","chensheng")
elif jsonData['android']['packageName'].find("chensheng") > 0 :
    jsonData['android']['packageName'] = jsonData['android']['packageName'].replace("chensheng","jufeng")

with open(desAssets, 'w') as file:
    json.dump(jsonData, file)

print("公司包名")
print(jsonData['android']['packageName'])
shutil.rmtree(dir_path+'\\file\\__pycache__')